package com.javabase.y2022.m04.day0412;

/**
 * @descriptions: Solution
 * @author: Tom
 * @date: 2022/4/12 下午 01:52
 * @version: 1.0
 */
public class Solution {
    public int[] numberOfLines(int[] widths, String s) {
        int start = 0;
        int N = s.length();
        int part = 0;
        int lines = 0;
        while(start < N){
            if(part + widths[(s.charAt(start)-'a')] <= 100){
                part += widths[(s.charAt(start)-'a')];
            } else {
                part = widths[(s.charAt(start)-'a')];
                lines++;
            }
            start++;
        }
        lines++;
        return new int[]{ lines, part};
    }

    public static void main(String[] args) {
        Solution s1 = new Solution();
        int[] widths = new int[]{4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
        String S = "bbbcccdddaaa";
        int[] ans;
        ans = s1.numberOfLines(widths, S);
        System.out.println(ans[0] + ":" + ans[1]);
    }
}
